'use strict';

const Service = require('egg').Service;

class UserService extends Service {
    async getUserById(accountId) {
        return await this.ctx.model.User.findOne({
            where: {
                id: accountId,
            },
        });
    }

    /**
     * 登陆
     * @param {*} account 账号
     * @param {*} password 密码
     * @returns 用户信息
     */
    async getUserLogin(account, password) {
        return await this.ctx.model.User.findOne({
            where: {
                user_account: account,
                user_password: password,
                user_display: 1,
            }
        });
    }

    async updateUserRouter(id) {
        return await this.ctx.model.User.findOne({
            where: {
                id: id
            }
        })
    }
}

module.exports = UserService;